-
-
Notifications
You must be signed in to change notification settings - Fork 281
refactor(changelog): better typing, yield #1453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
refactor(changelog): better typing, yield #1453
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1453 +/- ##
==========================================
+ Coverage 97.33% 97.62% +0.28%
==========================================
Files 42 57 +15
Lines 2104 2653 +549
==========================================
+ Hits 2048 2590 +542
- Misses 56 63 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
982859d
to
42a86cc
Compare
tests/test_changelog.py
Outdated
|
||
|
||
def test_order_changelog_tree_raises(): | ||
change_type_order = ["BREAKING CHANGE", "feat", "refactor", "feat"] | ||
with pytest.raises(InvalidConfigurationError) as excinfo: | ||
changelog.order_changelog_tree(COMMITS_TREE, change_type_order) | ||
list(changelog.order_changelog_tree(COMMITS_TREE, change_type_order)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added list
here for triggering the error.
commitizen/changelog.py
Outdated
"changes": OrderedDict( | ||
(ct, entry["changes"][ct]) | ||
for ct in change_type_order | ||
+ sorted(set(entry["changes"].keys()) - set(change_type_order)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make these 2 logics as functions to make it more readable.
42a86cc
to
b1f4853
Compare
def order_changelog_tree(tree: Iterable, change_type_order: list[str]) -> Iterable: | ||
def order_changelog_tree( | ||
tree: Iterable[Mapping[str, Any]], change_type_order: list[str] | ||
) -> Generator[dict[str, Any], None, None]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to make this type change, we probably would like to apply it on generate_tree_from_commits
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably.
I think using I didn't read it clearlyGenerator
as the return type is more accurate because an Iterable
can be iterated multiple times whereas Generator
cannot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
b1f4853
to
9e06722
Compare
Description
Checklist
Code Changes
poetry all
locally to ensure this change passes linter check and testsExpected Behavior
Steps to Test This Pull Request
Additional Context